package com.example.travelplan.app;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.util.SparseBooleanArray;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.Switch;

import static android.app.AlertDialog.*;


public class tabconfiguracaoActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tabconfiguracao);

        configurarAcoesBotoesMensagem();
        configurarAjuda();
        configurarMensagem();
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.tabconfiguracao, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    private void configurarAcoesBotoesMensagem() {
        ImageButton bt_avaliar = (ImageButton) findViewById(R.id.bt_avaliar);
        final Builder avaliacao = new Builder(this);
        bt_avaliar.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                avaliacao.setMessage("Obrigado por sua avaliação!");
                avaliacao.setTitle("Avaliação bem sucedida!");
                avaliacao.setPositiveButton("OK", null);
                avaliacao.setCancelable(true);
                avaliacao.show();

                avaliacao.setPositiveButton("Ok",
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                            }
                        }
                );
            }
        });

        ImageButton bt_mapas = (ImageButton) findViewById(R.id.bt_mapa);
        final Builder mapa = new Builder(this);
        bt_mapas.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                mapa.setMessage("Você está sendo redirecionado!");
                mapa.setTitle("Maps!");
                mapa.setPositiveButton("OK", null);
                mapa.setCancelable(true);
                mapa.show();

                mapa.setPositiveButton("Ok",
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                            }
                        }
                );
            }
        });

        ImageButton bt_curtir = (ImageButton) findViewById(R.id.bt_curtir);
        final Builder curtir = new Builder(this);
        bt_curtir.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                curtir.setMessage("Curtiu!");
                curtir.setTitle("Obrigado por curtir o TravelPlan!");
                curtir.setPositiveButton("OK", null);
                curtir.setCancelable(true);
                curtir.show();

                curtir.setPositiveButton("Ok",
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int which) {
                            }
                        }
                );
            }
        });


        Switch switch_som = (Switch) findViewById(R.id.sw_som);

        switch_som.setChecked(true);

        final ImageView bt_som = (ImageView) findViewById(R.id.bt_som);
        switch_som.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if (isChecked)
                    bt_som.setImageResource(R.drawable.ic_volume_on);
                else
                    bt_som.setImageResource(R.drawable.ic_volume_off);

            }
        });
    }

    public void configurarAjuda()
    {
        ImageButton bt_ajuda = (ImageButton)findViewById(R.id.bt_ajuda);
        final Intent intendMsn = new Intent(this, janelaResultadoBuscaAtividadesActivity.class);
        bt_ajuda.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                startActivity(intendMsn);
            }
        });
    }

    public void configurarMensagem()
    {
        ImageButton bt_email = (ImageButton)findViewById(R.id.bt_email);
        final Intent intendMsn = new Intent(this, janelaMensagemEmailActivity.class);
        bt_email.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                startActivity(intendMsn);
            }
        });
    }

}
